package com.mmp.main.servlet.report;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mmp.common.servlet.BasicServlet;
import com.mmp.main.entity.JobOrder;
import com.mmp.main.util.Default;
import com.mmp.main.util.Enums;

/**
 * Servlet implementation class ViewDevicesUnderMaintenance
 */
public class ViewDevicesUnderMaintenance extends BasicServlet {
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		JobOrder jobOrder = new JobOrder();
		jobOrder.setCancelled(false);
		jobOrder.setClosed(false);

		List<JobOrder> jobOrderList = dbm.find(jobOrder);
		if (jobOrderList == null || jobOrderList.isEmpty()) {
			announceErorrMessage(request, response, "لا يوجد أجهزة تحت الصيانة");
		} else {
			HashMap params = new HashMap();
			params.put(Default.REPORT_TITLE_PARAM_NAME, Enums.REPORT_TITLE.DEVICES_UNDER_MAINTENANCE.getReportTitle());
			params.put("jobOrderList", jobOrderList);
			viewPDFReport("rt2.jasper", null, params, response);
		}
	}

}
